package view;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;

import obj_file.Question;

import java.awt.Font;
import java.util.Random;

public class Help_3 extends JFrame {

	private int percent_1 ;
	private int percent_2 ;
	private int percent_3 ;
	private int percent_4 ;
	
	public Help_3(Question ques)
	{	
		//Frame
		setBounds(400, 20, 680, 680);
		this.setResizable(false);
		JPanel contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(null);
		setContentPane(contentPane);
		
		JLabel lblA = new JLabel("A");
		lblA.setFont(new Font("Tahoma", Font.PLAIN, 16));
		lblA.setBounds(24, 54, 22, 20);
		contentPane.add(lblA);		
		
		JLabel lbl_per_1 = new JLabel("");
		lbl_per_1.setFont(new Font("Tahoma", Font.PLAIN, 16));
		lbl_per_1.setBounds(56, 54, 22, 20);
		contentPane.add(lbl_per_1);
		
		JLabel lblB = new JLabel("B");
		lblB.setFont(new Font("Tahoma", Font.PLAIN, 16));
		lblB.setBounds(24, 85, 22, 20);
		contentPane.add(lblB);
		
		JLabel lbl_per_2 = new JLabel("");
		lbl_per_2.setFont(new Font("Tahoma", Font.PLAIN, 16));
		lbl_per_2.setBounds(56, 85, 22, 20);
		contentPane.add(lbl_per_2);
		
		JLabel lblC = new JLabel("C");
		lblC.setFont(new Font("Tahoma", Font.PLAIN, 16));
		lblC.setBounds(24, 116, 22, 20);
		contentPane.add(lblC);
		
		JLabel lbl_per_3 = new JLabel("");
		lbl_per_3.setFont(new Font("Tahoma", Font.PLAIN, 16));
		lbl_per_3.setBounds(56, 116, 22, 20);
		contentPane.add(lbl_per_3);
		
		JLabel lblD = new JLabel("D");
		lblD.setFont(new Font("Tahoma", Font.PLAIN, 16));
		lblD.setBounds(24, 147, 22, 20);
		contentPane.add(lblD);
		
		JLabel lbl_per_4 = new JLabel("");
		lbl_per_4.setFont(new Font("Tahoma", Font.PLAIN, 16));
		lbl_per_4.setBounds(56, 147, 22, 20);
		contentPane.add(lbl_per_4);
		
		percent_answers(ques);
		
		lbl_per_1.setText(Integer.toString(percent_1));
		lbl_per_2.setText(Integer.toString(percent_2));
		lbl_per_3.setText(Integer.toString(percent_3));
		lbl_per_4.setText(Integer.toString(percent_4));
		
		setVisible(true);
	}
	
	private void percent_answers(Question ques)
	{
		Random rand = new Random();
		if(ques.DapAnDung == 1 )
		{				
			percent_1 = 50 + rand.nextInt(50);
			percent_2 = rand.nextInt(100 - percent_1);
			percent_3 = rand.nextInt(100 - (percent_1 + percent_2));
			percent_4 = rand.nextInt(100 - (percent_1 + percent_2 + percent_3));
		}
		else if(ques.DapAnDung == 2 )
		{				
			percent_2 = 50 + rand.nextInt(50);
			percent_1 = rand.nextInt(100 - percent_2);
			percent_3 = rand.nextInt(100 - (percent_1 + percent_2));
			percent_4 = rand.nextInt(100 - (percent_1 + percent_2 + percent_3));
		}
		else if(ques.DapAnDung == 3 )
		{				
			percent_3 = 50 + rand.nextInt(50);
			percent_2 = rand.nextInt(100 - percent_3);
			percent_1 = rand.nextInt(100 - (percent_3 + percent_2));
			percent_4 = rand.nextInt(100 - (percent_1 + percent_2 + percent_3));
		}	
		if(ques.DapAnDung == 4 )
		{				
			percent_4 = 50 + rand.nextInt(50);
			percent_2 = rand.nextInt(100 - percent_4);
			percent_3 = rand.nextInt(100 - (percent_4 + percent_2));
			percent_1 = rand.nextInt(100 - (percent_4 + percent_2 + percent_3));
		}	
	}
}
